package com.jieshuibao.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jieshuibao.mapper.OfficialAdvisoryMapper;
import com.jieshuibao.mapper.UserExMapper;
import com.jieshuibao.model.db.OfficialAdvisory;
import com.jieshuibao.model.db.OfficialAdvisoryExample;
import com.jieshuibao.model.db.User;
@Service
public class OfficialAdvisoryService{
	
	@Resource
	private OfficialAdvisoryMapper officialAdvisoryMapper;
	
	@Resource
	private UserExMapper userExMapper;
	
	public void addOfficialAdvisory(OfficialAdvisory officialAdvisory) {
		officialAdvisoryMapper.insertSelective(officialAdvisory);
	}
	
	public void delOfficialAdvisoryByUuid(String uuid) {
		officialAdvisoryMapper.deleteByPrimaryKey(uuid);
	}
	
	public void updateOfficialAdvisory(OfficialAdvisory officialAdvisory) {
		officialAdvisoryMapper.updateByPrimaryKeySelective(officialAdvisory);
	}
	
	public OfficialAdvisory getOfficialAdvisoryByUuid(String uuid) {
		return officialAdvisoryMapper.selectByPrimaryKey(uuid);
	}
	
	public List<OfficialAdvisory> getPageOfficialAdvisory(OfficialAdvisoryExample officialAdvisoryExample) {
		return officialAdvisoryMapper.selectPage(officialAdvisoryExample);
	}
	
	public int countOfficialAdvisory(OfficialAdvisoryExample officialAdvisoryExample) {
		return officialAdvisoryMapper.countByExample(officialAdvisoryExample);
	}
	
	public void addOfficialAdvisoryAndUpdateUser(OfficialAdvisory officialAdvisory,User user){
		if(officialAdvisory!=null){
			officialAdvisoryMapper.insertSelective(officialAdvisory);
		}
		if(user!=null){
			userExMapper.updateUserAdvisoryNum(user);
		}
	}
}
